<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>H5素材统计</title>
</head>
<link href="<%=path %>/hplus/css/bootstrap.min.css" rel="stylesheet">
<link href="<%=path %>/hplus/css/animate.min.css" rel="stylesheet">
<link href="<%=path %>/hplus/css/style.min.css" rel="stylesheet">
<link href="<%=path %>/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/style.min.css"/>
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/datapicker/datepicker3.css">
<link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
<style>
  .col-sm-1{
        padding-right: 0;
    }
  body{
		font-size:12px;
		font-family:"宋体";
	}
  .label1{
  		font-size:15px;
  		margin-left:10px;
  		margin-top:15px;
  }
  .label2{
  		font-size:12px;
  		margin:10px;
  		margin-top:5px;
  }
  .row{
  		background-color:#fff;
  		margin:10px;  		
  }
  .click-count{
  		font-size:16px;
  		color:#1ab394;
  }
  .chart-line{
  		margin-top:-10px;
  		height:400px;
  		width:100%;
  }
  #datepicker{
		margin-left:10px;
	}
	.radio-primary input[type="radio"] + label::after {background-color: #1ab394;}
	.radio-primary input[type="radio"]:checked + label::after {background-color: #1ab394;}
	.radio-primary input[type="radio"]:checked + label::before {border-color: #1ab394;}
	.yellow_circle{
           width: 120px;
           height: 120px;
           background: #fee087;
           border-radius: 50%;
           padding-top: 30px;
           margin: 4px;            
       }

       .yellow_circle p{
           color: #333;
           text-align: center;
       }

       .yellow_circle p.people{
           color: #8f721c;
           font-size: 20px;
       }

       .yellow_circle_border{            
           width:130px;
           height:130px;
           border:1px solid #fee087;
           border-radius: 50%;
           margin-top:50px;
       }
       .s_col_sm_2{
       	   width:150px;
       	   height:150px;
       	   margin-left:30px;
       }
       .k_blue{
        	 border:1px solid #c9cff5;
        }
        
        .k_blue .yellow_circle{
        	background: #c9cff5;
        }
      .map{
      		height:500px;
      		width:800px;
      }
      .pie{
      	font-size:16px;
      	width:100%;
      	height:300px;
      	background-color: white;
      	margin-bottom: 20px;
      }
      .btn-primary{
      	float:right;
      }
      .search-table{
      	 font-size:12px;
      	 width:100%;
      }
      .map-title{ 
      float:left;
      cursor:pointer;
      }
      .map-title:hover{ 
      color:red;
      }
     .checkbox-text-activity {display: inline-block;*display: inline;*zoom: 1;width: 5em;height: 20px;line-height: 20px;font-size: 12px;overflow: hidden;-ms-text-overflow: ellipsis;text-overflow: ellipsis;white-space: nowrap;}
	 .icheckbox_square-green{vertical-align: top;}
	 .no-data-chart{text-align: center;line-height: 400px;font-size:16px;};
</style>
<body class="gray-bg">
	<div class="from-group">
		<div class="row" style="background-color:#f3f3f4;">
			<div class="form-group">
				<label class="col-sm-5 control-label"><a href="#" class="materialList">H5素材</a>><a href="#"class="materialName">H5素材名称</a>><span>素材统计</span></label>
			</div>
		</div>
	</div>
	<div class="from-group">
		<div class="row">
				<label class="col-sm-11 control-label label1"><label class="materialName">H5素材名称</label>统计</label>
				<div class="col-sm-12">
					<div class="input-daterange col-sm-2 date input-group" id="datepicker" style="float:left;">
						<input type="text" class="input-sm col-sm-1 form-control" name="start" onchange="startTimeChange()"  id="startDate" style="min-width:100px;">
		                <span class="input-group-addon" style="height: 24px;">到</span>
		                <input type="text" class="input-sm col-sm-1 form-control" name="end"  onchange="endTimeChange()"  id="endDate" style="min-width:100px;">		                
	           		</div>
					<div class="col-sm-3" style="max-width:240px;">
		           		<label class="col-sm-3" style="margin-top:10px; min-width:70px;">H5使用</label>
		           		<div class="radio radio-primary col-sm-2" style="min-width:60px;">
					                <input id="no_limit" type="radio" checked="checked" name="limit_activity" >
					                <label for="no_limit" style="min-width:40px;">不限</label>
			           	</div>
			           	<div class="radio radio-primary col-sm-2" style="margin-top:10px;min-width:60px;">
					                <input id="limit" type="radio"  name="limit_activity" >
					                <label for="limit" style="min-width:100px;">自定义</label>
			           	</div>
		           	</div>		
		           	<div class="col-sm-6 checkbox-activity" style="margin-top:10px;display:none;">
			           	<!-- <label class="col-sm-2 control-label checkbox-text" style="min-width:100px;"><input type="checkbox"><label data-id="1" style="margin-left:10px;">活动001</label></label>
			           	<label class="col-sm-2 control-label checkbox-text" style="min-width:100px;"><input type="checkbox"><label data-id="2" style="margin-left:10px;">活动002</label></label> 	
			           	<label class="col-sm-2 control-label checkbox-text" style="min-width:100px;"><input type="checkbox"><label data-id="3" style="margin-left:10px;">活动003</label></label>
			           	<label class="col-sm-2 control-label checkbox-text" style="min-width:100px;"><input type="checkbox"><label data-id="4" style="margin-left:10px;">活动004</label></label>
			           	<label class="col-sm-2 control-label checkbox-text" style="min-width:100px;"><input type="checkbox" ><label data-id="5" style="margin-left:10px;">活动005</label></label>			-->           	
			        </div>
			        <div class="col-sm-1 text-center" style="float:right;">
			        	<button class="btn btn-primary" type="button" id="search">搜索</button>
			        </div>    
           		</div>
           	 <div class="tab-content" >
           	 		   <div class="col-sm-1 col-circle"></div>
                       <div class="col-sm-2" id="visitCountCircle">
                       	<div class="s_col_sm_2">
			                <div class="yellow_circle_border ">							
			                    <div class="yellow_circle">                
			                        <p>访问次数</p >
			                        <p class="people"><span class="visit-count"></span></p >
			                    </div>                    
			                </div>
		                </div>
		            </div>
                       
                      <!--  <div class="col-sm-2" id="shareCountCircle">
                           <div class="s_col_sm_2">
			                <div class="yellow_circle_border k_blue">
			                    <div class="yellow_circle">                
			                        <p>分享次数</p >
			                        <p class="people"><span class="share-count"></span></p>
			                    </div>                    
			                </div>
		                </div>
		            </div> -->
                       <div class="col-sm-2" id="visitNumCircle">
                       	<div class="s_col_sm_2">
			                <div class="yellow_circle_border">
			                    <div class="yellow_circle">                
			                        <p>访问用户</p >
			                        <p class="people"><span class="visit-num"></span></p>
			                    </div>                    
			                </div>
		                </div>
		            </div>
                       
                       <div class="col-sm-2" id="shareNumCircle">
                           <div class="s_col_sm_2">
			                <div class="yellow_circle_border k_blue">
			                    <div class="yellow_circle">                
			                        <p>分享用户</p >
			                        <p class="people"><span class="share-num"></span></p >
			                    </div>                    
			                </div>			
		                </div>
		            </div>
		            <div class="col-sm-2" id="submitCircle">
                           <div class="s_col_sm_2">
			                <div class="yellow_circle_border">
			                    <div class="yellow_circle">                
			                        <p>提表用户</p >
			                        <p class="people"><span class="submit-num"></span></p >
			                    </div>                    
			                </div>			
		                </div>
		            </div>
		            <div class="col-sm-2" id="newCircle">
                           <div class="s_col_sm_2">
			                <div class="yellow_circle_border k_blue">
			                    <div class="yellow_circle">                
			                        <p>新增会员</p >
			                        <p class="people"><span class="new-member-num"></span></p >
			                    </div>                    
			                </div>			
		                </div>
		            </div>
		            <div class="col-sm-1 col-circle"></div>
			     </div>
		</div>
	</div>
	<div class="from-group">
		 <div class="wrapper wrapper-content">
			     <div class="tabs-container">
				    <ul class="nav nav-tabs">
		                <li class="active"><a data-toggle="tab" href="#tab-line" data-tab="tab-line" aria-expanded="true" >数据趋势</a>
		                </li>
				   	</ul>
				</div>
		 <div class="tab-content">
		     <div class="ibox-content tab-pane active" id="tab-line">
		     	<div class="chart-line"></div>
		     </div>
	     </div>
	</div>
	<div class="from-group">
	   <div class="wrapper wrapper-content">
			     <div class="tabs-container">
				    <ul class="nav nav-tabs">
		                <li class="active"><a data-toggle="tab" id="toggle-access" href="#tab-access" data-tab="tab-access" data-id="access" aria-expanded="true" >访问数据</a>
		                </li>
		                <li><a data-toggle="tab" data-tab="tab-spread" id="toggle-share" href="#tab-spread" data-id="share" aria-expanded="false">传播数据</a>
		                </li>
		                <li class=""><a data-toggle="tab" data-tab="tab-submit" id="toggle-submit" data-id="submit"  href="#tab-submit-map" aria-expanded="false">提表用户</a>
		                </li>
		                <li><a data-toggle="tab" data-tab="tab-write-off" id="toggle-write-off" href="#tab-write-off" data-id="write-off"  aria-expanded="false">核销用户</a>
		                </li>
		                <li><a data-toggle="tab" data-tab="tab-new" id="toggle-new" href="#tab-new" data-id="new-member" aria-expanded="false">新增用户</a>
		                </li>
				   	</ul>
				</div>
		 <div class="tab-content">
		     <div class="ibox-content tab-pane active" id="tab-access" data-id="access">
		     	<div class="row">
		     		<span class="map-title" data-id="access">全国视图</span>
			     	<div class="col-sm-7 map access-map">
			     	
			     	</div>
			     	<div class="col-sm-4">
			     		<table class="table table-bordered table-striped table-hover" style="font-size:12px;">
			     			<tr>
			     				<th>地区</th>
			     				<th>访问用户数</th>
			     				<th>分享用户数</th>
			     				<th>传播占比</th>
			     			</tr>
			     			<tbody class="access-table"></tbody>
			     		</table>
			     	</div>
			    <div class="form-group col-sm-12">	
				<div class="row pie access-pie">
					<div class="col-sm-4 text-center">
						<label>用户性别</label>
						<div class="access-pie-sex" style="height: 300px;"></div>
					</div>
					<div class="col-sm-4 text-center">
						<label >操作系统</label>
						<div class="access-pie-system" style="height: 300px;"></div>
					</div>
					<div class="col-sm-4 text-center">
						<label >访客来源</label>
						<div class="access-pie-source" style="height: 300px;"></div>
					</div>
				</div>
				</div>
		     	</div>
		     </div>
		     <div class="ibox-content tab-pane" id="tab-spread" data-tab="share">
		    	 <div class="row">
		    	 	<span class="map-title" data-id="share">全国视图</span>
			     	<div class="col-sm-7 map share-map">
			     		
			     	</div>
			     	<div class="col-sm-4">
			     		<table class="table table-bordered table-striped table-hover" style="font-size:12px;">
			     			<tr>
			     				<th>地区</th>
			     				<th>分享用户数</th>
			     			</tr>
			     			<tbody class="share-table">
			     			
			     			</tbody>
			     		</table>
			     	</div>
			     	<div class="form-group col-sm-12">	
						<div class="row pie share-pie">
							<div class="col-sm-4 text-center">
								<label>用户性别</label>
								<div class="share-pie-sex" style="height: 300px;"></div>
							</div>
							<div class="col-sm-4 text-center">
								<label >操作系统</label>
								<div class="share-pie-system" style="height: 300px;"></div>
							</div>
							<div class="col-sm-4 text-center">
								<label >访客来源</label>
								<div class="share-pie-source" style="height: 300px;"></div>
							</div>
						</div>
					</div>
		     	</div>
		     </div>
		     <div class="ibox-content tab-pane" id="tab-submit-map">
		     	<div class="row">
		     		<span class="map-title" data-id="submit">全国视图</span>
			     	<div class="col-sm-7 map submit-map" >
			     		
			     	</div>
			     	<div class="col-sm-4">
			     		<table class="table table-bordered table-striped table-hover" style="font-size:12px;">
			     			<tr>
			     				<th>地区</th>
			     				<th>提表用户数</th>
			     			</tr>
			     			<tbody class="submit-table">
			     				
			     			</tbody>
			     		</table>
			     	</div>
			     	<div class="form-group col-sm-12">	
						<div class="row pie submit-pie">
							<div class="col-sm-4 text-center">
								<label>用户性别</label>
								<div class="submit-pie-sex" style="height: 300px;"></div>
							</div>
							<div class="col-sm-4 text-center">
								<label >操作系统</label>
								<div class="submit-pie-system" style="height: 300px;"></div>
							</div>
							<div class="col-sm-4 text-center">
								<label >访客来源</label>
								<div class="submit-pie-source" style="height: 300px;"></div>
							</div>
						</div>
					</div>
			     </div>
		     </div>
		     <div class="ibox-content tab-pane" id="tab-write-off" data-id="write-off">
		   		  <div class="row">
		   		  	<span class="map-title" data-id="write-off">全国视图</span>
			     	<div class="col-sm-7 map write-off-map">
			     		
			     	</div>
			     	<div class="col-sm-4">
			     		<table class="table table-bordered table-striped table-hover" style="font-size:12px;">
			     			<tr>
			     				<th>地区</th>
			     				<th>核销用户数</th>
			     			</tr>
			     			<tbody class="write-off-table"></tbody>
			     		</table>
			     	</div>
			     	<div class="form-group col-sm-12">	
						<div class="row pie">
							<div class="col-sm-4 text-center">
								<label>用户性别</label>
								<div class="write-off-pie-sex" style="height: 300px;"></div>
							</div>
							<div class="col-sm-4 text-center">
								<label >操作系统</label>
								<div class="write-off-pie-system" style="height: 300px;"></div>
							</div>
							<div class="col-sm-4 text-center">
								<label >访客来源</label>
								<div class="write-off-pie-source" style="height: 300px;"></div>
							</div>
						</div>
					</div>
			     </div>
		     </div>
		     <div class="ibox-content tab-pane" id="tab-new">
		   	  	<div class="row">
		   	  		<span class="map-title" data-id="new-member">全国视图</span>
			     	<div class="col-sm-7 map new-member-map">
			     					     		
			     	</div>
			     	<div class="col-sm-4">
			     		<table class="table table-bordered table-striped table-hover" style="font-size:12px;">
			     			<tr>
			     				<th>地区</th>
			     				<th>新增会员数</th>
			     			</tr>
			     			<tbody class="new-member-table">
			     			
			     			</tbody>
			     		</table>
			     	</div>
			     	<div class="form-group col-sm-12">	
						<div class="row pie new-member-pie">
							<div class="col-sm-4 text-center">
								<label>用户性别</label>
								<div class="new-member-pie-sex" style="height: 300px;"></div>
							</div>
							<div class="col-sm-4 text-center">
								<label >操作系统</label>
								<div class="new-member-pie-system" style="height: 300px;"></div>
							</div>
							<div class="col-sm-4 text-center">
								<label >访客来源</label>
								<div class="new-member-pie-source" style="height: 300px;"></div>
							</div>
						</div>
					</div>
		     	</div>
		     </div>
	     </div>
	</div>
	</div>
</div>
	<div class="from-group">
		 <div class="wrapper wrapper-content">
			     <div class="tabs-container">
				    <ul class="nav nav-tabs">
		                <li class="active"><a data-toggle="tab" href="#tab-share" data-tab="tab-share" aria-expanded="true" >访问&传播用户详情</a>
		                </li>
		                <shiro:hasPermission name="count_mic:export_visit_csv">
		               <button class="btn btn-primary export-share" type="button">导出CSV</button>
		               </shiro:hasPermission>
				   	</ul>
				</div>
		 <div class="tab-content ">
		     <div class="ibox-content tab-pane active" id="tab-share">
		       <div class="form-group">
		       		<div class="row">
						<div class="col-sm-12">
							<table class="table table-bordered table-striped table-hover search-table" id="shareTable" >
								<thead>
								 <tr>
				     				<th>用户</th>
				     				<th>性别</th>
				     				<th>地区</th>
				     				<th>身份</th>
				     				<th>访问来源</th>
				     				<th>最近关注时间</th>
				     				<th>二次传播用户数</th>
				     			</tr>
								</thead>
								<tbody>
								</tbody>
							</table>
						</div>
					</div>
				</div>
		     </div>
	     </div>
	</div>
</div>
	<div class="from-group" id="submit-table">
		 <div class="wrapper wrapper-content">
			     <div class="tabs-container">
				    <ul class="nav nav-tabs">
		                <li class="active"><a data-toggle="tab" href="#tab-submit" data-tab="tab-submit" aria-expanded="true" >提表用户详情</a>
		                </li>
		                 <shiro:hasPermission name="count_mic:export_submit_csv">
		                <button class="btn btn-primary export-submit" type="button">导出CSV</button>
		                </shiro:hasPermission>
				   	</ul>
				</div>
		 <div class="tab-content">
		     <div class="ibox-content tab-pane active" id="tab-submit">
			     <div class="form-group">
			     	<div class="row">
						<div class="col-sm-12">
							<table class="table table-bordered table-striped table-hover search-table" id="submitTable">
								<thead>
									<tr>
					     				<th>用户</th>
					     				<th>手机</th>
					     				<th>性别</th>
					     				<th>身份</th>
					     				<th>访问来源</th>
					     				<th>提表时间</th>
					     				<th>核销状态</th>
				     				</tr>
								</thead>
								<tbody>
								</tbody>
							</table>
						</div>
						</div>
					</div>
			    <!-- <div class="m_xpages share_m_xpages" style="width:100%;margin:0;padding: 2px 0 1px 0;">
					<div class="mian share_mian" style="margin-left: 400px;">
						<span>显示行数</span> <select><option>10</option>
							<option>20</option>
							</select> <span>共0条</span> <span>1/1页</span> <a
							href="javascript:;" class="prev share_prev">上一页</a> <a href="javascript:;"
							class="next share_next">下一页</a> <span>前往</span> <input type="text share_text" value="1"
							class="text share_text"> <span>页</span>
					</div>
				</div> -->
		     </div>
	     </div>
	</div>
	</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/3.6.1/echarts.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/marketing/public.js"></script>
<script type="text/javascript" src="<%=path%>/hplus/js/plugins/datapicker/bootstrap-datepicker.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/artDialog/7.0.0/dialog-plus.js"></script>
<script src="<%=path%>/hplus/js/plugins/iCheck/icheck.min.js"></script>
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/china.js"></script> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="<%=path%>/js/system/province-city-area-data.js"></script>
<script type="text/javascript">
var path = "<%=path%>";
$.fn.dataTable.ext.errMode = 'none';
//素材id
var materialId = getQueryString("materialId");
var materialName = decodeURI(getQueryString("materialName"));
//是否需要收集信息 1表示需要 0不需要
var isNeedCollect = getQueryString("isNeedCollect");
var shareTable;
var submitTable;
var searchData = new Object();
var allAemIds;
//限制可选开始时间
var limitStartTime;
//限制可选结束时间
var limitEndTime;
//materialId='1016207679225466880';
//materialName="全员营销活动素材-majie";
$(function(){
	$(":checkbox").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});
	$(".input-daterange").datepicker({keyboardNavigation: !1, forceParse: !1, autoclose: !0});
	initDate();
	$('#startDate').datepicker({
		todayBtn : "linked",
		autoclose : true,
		todayHighlight : true,
		endDate : new Date(limitEndTime)
	}).on('changeDate',function(e){
		var startTime = e.date;
		$('#endDate').datepicker('setStartDate',startTime);
	});
	//结束时间：
	$('#endDate').datepicker({
		todayBtn : "linked",
		autoclose : true,
		todayHighlight : true,
		endDate : new Date(limitEndTime)
	}).on('changeDate',function(e){
		var endTime = e.date;
		$('#startDate').datepicker('setEndDate',endTime);
	});
	//初始化页面元素
	initActivityList();	
	initHtmlContent();
	shareTable=shareDataTable();
	submitTable=submitDataTable();
	//查询素材类型
	hideHtmlContent();
});
//隐藏搜集信息的相关统计
function hideHtmlContent(){
	if(searchData.isNeedCollect==0){
		$("#toggle-submit").hide();
		$("#toggle-write-off").hide();
		$("#toggle-new").hide();
		$("#submitCircle").hide();
		$("#newCircle").hide();
		$("#visitNumCircle").attr("class","col-sm-4");
		$("#visitCountCircle").attr("class","col-sm-4");
		//$("#shareCountCircle").attr("class","col-sm-3");
		$("#shareNumCircle").attr("class","col-sm-4");
		$("#submit-table").hide();
		$(".col-circle").hide();
	}
	if(!StringEmpty(searchData.couponIds)){
		$("#toggle-write-off").hide();
	}
}
//初始化页面的元素
function initHtmlContent(){
	getSearchData();
	getCountData();
	$(".materialName").html(materialName);	
	$(".materialName").click(function(){
		window.location.href = path+"/material/teletextMaterialCreate?handleType=edit&id="+materialId;
	})
	$(".materialList").click(function(){
		window.location.href = path+ "/material/materialList";	
	});
	var value = document.body.clientWidth-20;
	$(".access-map")[0].style.width=(value)/14*7+"px";
	$(".access-pie-sex")[0].style.width=(value-100)/3+"px";
	$(".access-pie-system")[0].style.width=(value-100)/3+"px";
	$(".access-pie-source")[0].style.width=(value-100)/3+"px";
	chinaMap("access");
	initSexPie("access");
	initSystemPie("access");
	initSourcePie("access");
}
//时间控制
function startTimeChange(){
	 var startTime=$('#startDate').val();
	 var endTime=$('#endDate').val();		   
	 if(CompareDate(startTime,endTime)){
		 $('#endDate').val(startTime);
	 }
}
function endTimeChange(){
   	 var startTime=$('#startDate').val();
	 var endTime=$('#endDate').val();		   
	 if(CompareDate(startTime,endTime)){
		 $('#endDate').val(endTime);
	 }
}
function CompareDate(d1,d2)
{
  return ((new Date(d1.replace(/-/g,"\/"))) > (new Date(d2.replace(/-/g,"\/"))));
}
//初始化时间控件
function initDate(){
	var initDateUrl = path+"/materialCount/findMaterialByDto";
	var material;
	//查询素材的限制时间信息
	$.ajax({
		type : "post",
		url : initDateUrl,
		async : false,
		data : {
			"id" : materialId
		},
    	success : function(data){
    	  if(data.status="200"){
    		  material=data.data;
    	  }
    	}
    });
	//限制时间控件的选择时间
	if(material!=null){
		searchData.isNeedCollect=material.isNeedCollect;
		searchData.couponIds=material.couponIds;
		var validityType=material.validityType;
		if(validityType==0){
			//没有有效期  则默认为创建时间至昨天
			limitStartTime = new Date(material.createTime);			
			limitEndTime = new Date(new Date().getTime() - 1 * 60 * 60 * 1000 * 24);
			if(limitStartTime>limitEndTime){
				limitStartTime = limitEndTime;
			}
		}else{
			//有固定有效期
			var startTime = material.startTime;
			var endTime = material.endTime;
			var nowTime = new Date();
			//1.已结束素材：默认时间为H5素材有效期开始时间－H5素材有效期结束时间
			if(endTime<nowTime){
				limitStartTime = startTime;
				limitEndTime = endTime;
			}else{
				//2.有效期内素材：默认时间为最近7天，当前日期为T，默认时间为T-7～T-1，素材有效期开始不足7天时，显示开始时间～T-1
				var weekTime = new Date(new Date().getTime() - 7 * 60 * 60 * 1000 * 24);
				limitEndTime = new Date(new Date().getTime() - 1 * 60 * 60 * 1000 * 24);
				if(startTime>weekTime){
					limitStartTime = startTime;
				}else{
					limitStartTime = weekTime;
				}
			}
		}		
		//limitStartTime = "2018-07-01";
		//limitEndTime = "2018-07-31";
		var starDate = new Date(limitStartTime);
		var endDate = new Date(limitEndTime); 	
		startDate = timeFormat(starDate);
		$("#startDate").val(startDate);
		endDate =  timeFormat(endDate);
		$("#endDate").val(endDate);
		$('#startDate').datepicker('setStartDate',startDate);
		$('#startDate').datepicker('setEndDate',endDate);
		$('#endDate').datepicker('setStartDate',startDate);
		$('#endDate').datepicker('setEndDate',endDate);
	}
}

//按指定条件查询
$("#search").click(function(){
	initHtmlContent();
	shareTable.ajax.reload();
	submitTable.ajax.reload();
})
//切换tab初始化
$("a[data-toggle='tab']").click(function(){	
	$(".map-title").html("全国视图")
	searchData.cityCode=null;
	var value = document.body.clientWidth-20;
	var id = $(this).data("id");
	if(id=="access"){
		searchData.countType=0;
	}else
	if(id=="share"){
		searchData.countType=1;
	}else	
	if(id=="submit"){
		searchData.countType=2;
	}else
	if(id=="write-off"){
		searchData.countType=3;
	}else
	if(id=="new-member"){
		searchData.countType=4;
	}
	$("."+id+"-map")[0].style.width=(value)/14*7+"px";
	$("."+id+"-pie-sex")[0].style.width=(value-100)/3+"px";
	$("."+id+"-pie-system")[0].style.width=(value-100)/3+"px";
	$("."+id+"-pie-source")[0].style.width=(value-100)/3+"px";
	initSexPie(id);
	initSystemPie(id);
	initSourcePie(id);
	chinaMap(id);
	/* var temp = new chinaMap(id);
	temp.resize(); */
})
//获取选中的查询条件
function getSearchData(){
	var startDate = $("#startDate").val();
	var endDate = $("#endDate").val();
	searchData.startDate = startDate;
	searchData.endDate = endDate;
	if($("#limit").is(":checked")){
		var aemArray = new Array();
		$('input:checkbox').each(function() { 		
            if ($(this).is(':checked')) { 
            	var aemInfo = new Object();
            	$label=$(this).parent().parent().children("label");
            	aemInfo.aemId = $label.data("id");
            	aemInfo.aemName = $label.val();
            	aemArray.push(aemInfo);
            }           
       });
		searchData.aemArray = aemArray;
		if(StringEmpty(aemArray)){
			var aemIds="";
			for(var i=0;i<aemArray.length;i++){
				if(i+1==aemArray.length){
					aemIds+=aemArray[i].aemId;
				}else{
					aemIds+=aemArray[i].aemId+",";
				}
			}
			searchData.aemIds=aemIds;
		}
	}else if(StringEmpty(allAemIds)){
		searchData.aemIds=allAemIds;
	}else{
		searchData.aemIds=0;
	}
	searchData.cityCode=null;
	searchData.countType=0;
	return searchData;
}
//初始化活动集合
function initActivityList(){
	var activityList;
	var activityUrl = path+"/materialCount/findActivityListByMaterialId";
	$.ajax({
		type:"post",
		url:activityUrl,
		async: false,
		data:{
			"mgiId":materialId
		},
    success:function(data){
    	if(data.status=="200"){
    		activityList=data.data;
    	}
   	  }
	}); 	
	if(StringEmpty(activityList)){
		var checkBoxHtml='';
		var aemIds = "";
		for(var i=0;i<activityList.length;i++){
			checkBoxHtml+='<label class="col-sm-2 control-label checkbox-text" style="min-width:150px;min-height:50px;"><input type="checkbox">';
			checkBoxHtml+='<label class="checkbox-text-activity" title="'+activityList[i].name+'" data-id="'+activityList[i].id+'" style="margin-left:10px;">'+activityList[i].name+'</label></label>';	
			if(i+1==activityList.length){
				aemIds+=activityList[i].id;
			}else{
				aemIds+=activityList[i].id+",";
			}
		}
		searchData.aemIds = aemIds;
		allAemIds = aemIds;
		if(!StringEmpty(aemIds)){
			searchData.aemIds=0;
		}
		$(".checkbox-activity").html(checkBoxHtml);
		$(":checkbox").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});
	}	
}
//获取统计数据
function getCountData(){
	var sumVisitCount =0;
	var sumVisitNum =0;
	var sumShareCount =0;
	var sumShareNum =0;
	var sumSubmitNum =0;
	var sumNewMemebrNum =0;
	var countUrl = path+"/materialCount/findMaterialCount";
	$.ajax({
		type:"post",
		url:countUrl,
		async: true,
		data:{
			"startDate" :searchData.startDate,
	  		"endDate" :searchData.endDate,
	  		"aemIds" :searchData.aemIds
		},
    success:function(data){
    	if(data.status=="200"){
    		var countData = data.data;   		
    		for(var i=0;i<countData.length;i++){
    			var count = countData[i];  
    			sumVisitCount+=parseInt(count.visitCount);
    			sumVisitNum+=parseInt(count.visitNum);
    			sumShareCount+=parseInt(count.shareCount);
    			sumShareNum+=parseInt(count.shareNum);
    			sumSubmitNum+=parseInt(count.submitNum);
    			sumNewMemebrNum+=parseInt(count.newMemberNum);
    			chartLine(countData);
    		}    		
    	}else{
			chartLine(null);
		}
    	$(".visit-count").html(sumVisitCount);
		$(".visit-num").html(sumVisitNum);
		$(".share-count").html(sumShareCount);
		$(".share-num").html(sumShareNum);
		$(".submit-num").html(sumSubmitNum);
		$(".new-member-num").html(sumNewMemebrNum);
   	  }
	});
}
//不限
$("#no_limit").click(function(){
	$(".checkbox-activity").hide();
})
//自定义
$("#limit").click(function(){
	$(".checkbox-activity").show();
})
//折线图控件
function chartLine(lineData){
	var lineChart = echarts.init($(".chart-line")[0]);
	lineChart.showLoading();  
	//折线图数据对象
	var chartLineData = new Object();
	var legendData =['访问次数','访问用户','分享用户','提表用户','新增用户'];
	var xData = new Array();
	var yData = new Array();
	var visitCountArray = new Array();
	var visitNumArray = new Array();
	//var shareCountArray = new Array();
	var shareNumArray = new Array();
	var submitNumArray = new Array();
	var newMemberNumArray = new Array();
	if(!StringEmpty(lineData)){	
		/* var date = new Date(startDate);
		var y = date.getFullYear();    
		var m = date.getMonth()+1;//获取当前月份的日期   
		var d = date.getDate(); 	
		xData.push(y+"-"+m+"-"+d);
		lineChart.hideLoading();  
		lineChart.clear();  
		visitCountArray.push(0);
		visitNumArray.push(0);
		//shareCountArray.push(0);
		shareNumArray.push(0);		
		submitNumArray.push(0);
		newMemberNumArray.push(0); */
		lineChart.hideLoading();  
		$(".chart-line").addClass("no-data-chart");
		$(".chart-line").html("暂无数据");
		return null;
	}else{
		for(var i=0;i<lineData.length;i++){
			var count = lineData[i];
			var date = new Date(count.createTime);
			xData.push(timeFormat(date));
			visitCountArray.push(parseInt(count.visitCount));
			visitNumArray.push(parseInt(count.visitNum));
			//shareCountArray.push(count.shareCount);
			shareNumArray.push(parseInt(count.shareNum));		
			submitNumArray.push(parseInt(count.submitNum));
			newMemberNumArray.push(parseInt(count.newMemberNum));
		}
	}
	var series = new Object();
	series.name="访问次数";
	series.type="line";
	//series.stack="数量";
	series.symbol="circle";
	series.symbolSize=6;
	series.data=visitCountArray;
	yData.push(series);
	series = new Object();
	series.type="line";
	//series.stack="数量";
	series.symbol="circle";
	series.smooth=true;
	series.symbolSize=6;
	series.name="访问用户";
	series.data=visitNumArray;
	 yData.push(series);
	/*series = new Object();
	series.type="line";
	series.stack="数量";
	series.symbol="circle";
	series.symbolSize=6;
	series.smooth=true;
	series.name="分享次数";
	series.data=shareCountArray;
	yData.push(series); */
	series = new Object();
	series.type="line";
	//series.stack="数量";
	series.symbol="circle";
	series.smooth=true;
	series.symbolSize=6;
	series.name="分享用户";
	series.data=shareNumArray;
	yData.push(series);
	if(searchData.isNeedCollect==0){
	legendData=['访问次数','访问用户','分享用户'];
	}else{
		series = new Object();
		series.type="line";
		//series.stack="数量";
		series.symbol="circle";
		series.smooth=true;
		series.symbolSize=6;
		series.name="提表用户";
		series.data=submitNumArray;
		yData.push(series);
		series = new Object();
		series.type="line";
		//series.stack="数量";
		series.symbol="circle";
		series.smooth=true;
		series.symbolSize=6;
		series.name="新增用户";
		series.data=newMemberNumArray;
		yData.push(series);
	}
	chartLineData.legendData=legendData;
	chartLineData.xData=xData;
	chartLineData.yData=yData;
	lineChart.hideLoading();  
	var lineOption = {
		    tooltip: {
		        trigger: 'axis'
		    },
		    legend: {
		        data:chartLineData.legendData
		    },
		    color:['#1BB495','#ED5565','#F8AC59','#1D84C6','#A8BAD6'],
		    grid: {
		        left: '3%',
		        right: '4%',
		        bottom: '3%',
		        containLabel: true
		    },
		    toolbox: {
		        feature: {
		            saveAsImage: {}
		        }
		    },
		    xAxis: {
		        type: 'category',
		        boundaryGap: false,
		        data: chartLineData.xData
		    },
		    yAxis: {
		        type: 'value'
		    },
		    series:chartLineData.yData
		};
	lineChart.setOption(lineOption);
}
//地图控件
function chinaMap(mapClass){
	var mapChart = echarts.init($("."+mapClass+"-map")[0]);
	mapChart.showLoading();
	var provinceData = new Array();
	var initChinaUrl = path+"/materialCount/findMapCount";
	var mapData;
	$.ajax({
		type:"post",
		url:initChinaUrl,
		async: false,
		data:{
			"startDate" : searchData.startDate,
	  		"endDate" : searchData.endDate,
	  		"aemIds" : searchData.aemIds,
	  		"countType" : searchData.countType
		},
    	success:function(data){
    	  if(data.status="200"){
      		mapData=data.data;
    	  }
    	}
    });
	provinceData=[
	{name: '北京',value: 0},
    {name: '天津',value: 0},
    {name: '上海',value: 0},
    {name: '重庆',value: 0},
    {name: '河北',value: 0},
    {name: '河南',value: 0},
    {name: '云南',value: 0},
    {name: '辽宁',value: 0},
    {name: '黑龙江',value:0},
    {name: '湖南',value: 0},
    {name: '安徽',value: 0},
    {name: '山东',value: 0},
    {name: '新疆',value: 0},
    {name: '江苏',value: 0},
    {name: '浙江',value: 0},
    {name: '江西',value: 0},
    {name: '湖北',value: 0},
    {name: '广西',value: 0},
    {name: '甘肃',value: 0},
    {name: '山西',value: 0},
    {name: '内蒙古',value:0},
    {name: '陕西',value: 0},
    {name: '吉林',value: 0},
    {name: '福建',value: 0},
    {name: '贵州',value: 0},
    {name: '广东',value: 0},
    {name: '青海',value: 0},
    {name: '西藏',value: 0},
    {name: '四川',value: 0},
    {name: '宁夏',value: 0},
    {name: '海南',value: 0},
    {name: '台湾',value: 0},
    {name: '香港',value: 0},
    {name: '澳门',value: 0}
	];
	if(StringEmpty(mapData)){
		for(var i=0;i<mapData.length;i++){
			var code = mapData[i].cityCode+"000";
			for(var j=0;j<provinceData.length;j++){				
				var provinceCode = getCodeByName(provinceData[j].name);
				if(provinceCode==code){
					provinceData[j].value = mapData[i].materialCount;
				}
			}
		}
	}
	initTable(mapClass);
	mapChart.hideLoading();
    var mapOption = {
        tooltip : {//提示框组件。
            trigger: 'item'//数据项图形触发，主要在散点图，饼图等无类目轴的图表中使用。
        },
        legend: {
            orient: 'horizontal',//图例的排列方向
            x:'left',//图例的位置
            data:['数量'],
            show:false
        },
        visualMap: {//颜色的设置  dataRange
            x: 'left',
            y: 'bottom',
/*            splitList: [
                {start: 1500},
                {start: 900, end: 1500},
                {start: 310, end: 1000},
                {start: 200, end: 300},
                {start: 10, end: 200, label: '10 到 200（自定义label）'},
                {start: 5, end: 5, label: '5（自定义特殊颜色）', color: 'black'},
                {end: 10}
            ], */
            min: 0,
            max: provinceData[0].value,
            calculable : true,//颜色呈条状
            text:['高','低'],// 文本，默认为数值文本
            color: ['#1D84C6','#DCFBFD']
        },
        toolbox: {//工具栏
            show: true,
            orient : 'vertical',//工具栏 icon 的布局朝向
            x: 'right',
            y: 'center',
            feature : {//各工具配置项。
                mark : {show: true},
                dataView : {show: true, readOnly: false},//数据视图工具，可以展现当前图表所用的数据，编辑后可以动态更新。
                restore : {show: true},//配置项还原。
                saveAsImage : {show: true}//保存为图片。
            }
        },
        roamController: {//控制地图的上下左右放大缩小 图上没有显示
            show: true,
            x: 'right',
            mapTypeControl: {
                'china': true
            }
        },
        series : [
            {
                name: '数量',
                type: 'map',
                mapType: 'china',
                roam: true,//是否开启鼠标缩放和平移漫游
                itemStyle:{//地图区域的多边形 图形样式
                    normal:{//是图形在默认状态下的样式
                        label:{
                            show:true,//是否显示标签
                            textStyle: {
                                color: "#FD7D51"
                            }
                        }
                    },
                    emphasis:{//是图形在高亮状态下的样式,比如在鼠标悬浮或者图例联动高亮时
                        label:{show:true}
                    }
                },
                top:"3%",//组件距离容器的距离
                data:provinceData
            }
        ]
    };
    mapChart.setOption(mapOption);
    mapChart.on('click', function (params) {
    	$(".map-title").html("返回全国视图")
        var dataIndex = params.name;
        var code = getCodeByName(dataIndex);
        searchData.cityCode = code.substring(0,3);
        initTable(mapClass);
        initSexPie(mapClass);
        initSystemPie(mapClass);
        initSourcePie(mapClass);
    }); 
/*      $(function(){
        window.onresize = function(){
        	mapChart.resize();
        }
    })
    this.resize = function size(){
        var childDiv=$(".submit-map>div")[0];
        var tabcontent = $(".submit-map")[0];
        width=tabcontent.offsetWidth;
        height=tabcontent.offsetHeight;
        childDiv.style.width=width+'px';
        childDiv.style.height=height+'px';
        mapChart.resize(width,height);
    }
     */
}
//点击地图上方
$(".map-title").click(function(){
		searchData.cityCode=null;
		$(this).html("全国视图");
		var id=$(this).data("id");
		initTable(id);
		initSexPie(id);
		initSystemPie(id);
		initSourcePie(id);
});
//初始化列表
function initTable(type){
	var initChinaUrl = path+"/materialCount/findMapCount";
	var mapData;
	$.ajax({
		type:"post",
		url:initChinaUrl,
		async: false,
		data:{
			"startDate" : searchData.startDate,
	  		"endDate" : searchData.endDate,
	  		"aemIds" : searchData.aemIds,
	  		"cityCode" :searchData.cityCode,
	  		"countType" : searchData.countType
		},
    	success:function(data){
    	  if(data.status="200"){
    		  mapData=data.data;
    	  }
    	}
    });
	var tableHtml="";
	if(StringEmpty(mapData)){
		for(var i=0;i<mapData.length;i++){
			if(i==10){
				break;
			}
			var tableData = mapData[i];
			var code = ""+tableData.cityCode;
			var name ="未知";
			if(StringEmpty(searchData.cityCode)){
				if(StringEmpty(getNameByCode(code))){
					name=getNameByCode(code);
				}	
			}else{
				if(StringEmpty(getNameByCode(code+"000"))){
					name=getNameByCode(code+"000");
				}
			}
			tableHtml+="<tr>";
			tableHtml+="<td>"+name+"</td>";
			tableHtml+="<td>"+tableData.materialCount+"</td>";
			if(searchData.countType==0){			
				var visitCount = tableData.materialCount;
				var shareCount = tableData.shareCount;
				var percentage = "0%";
				if (!isNaN(visitCount)&&!isNaN(shareCount)) {
					percentage=Math.round(shareCount/visitCount*10000)/100+"%";					
			    }
				tableHtml+="<td>"+shareCount+"</td>";
				tableHtml+="<td>"+percentage+"</td>";
			}
			tableHtml+="</tr>";
		}
	}
	$("."+type+"-table").html(tableHtml);
}
//性别环形图初始化
function initSexPie(type){
	var sexPie = echarts.init($("."+type+"-pie-sex")[0]);
	sexPie.showLoading();
	var initPieUrl = path+"/materialCount/findSexCount";
	var pieData;
	var sexData = new Array();
	$.ajax({
		type:"post",
		url:initPieUrl,
		async: false,
		data:{
			"startDate" : searchData.startDate,
	  		"endDate" : searchData.endDate,
	  		"aemIds" : searchData.aemIds,
	  		"cityCode" :searchData.cityCode,
	  		"countType" : searchData.countType
		},
    	success:function(data){
    	  if(data.status="200"){
    		  pieData=data.data;
    	  }
    	}
    });
	sexData=[{"name":"男","value":"0"},{"name":"女","value":"0"},{"name":"未获取","value":"0"}];
	if(StringEmpty(pieData)){
		for(var i=0;i<pieData.length;i++){
			var data = new Object();
			var name =pieData[i].sex=="m"?"男":pieData[i].sex=="f"?"女":"未获取";
			var value=pieData[i].materialCount;
			for(var j=0;j<sexData.length;j++){
				var sex = sexData[j];
				if(name==sex.name){
					sex.value=value;
				}
			}
		}
	}
	sexPie.hideLoading();
	var sexOption = {
		    tooltip: {
		        trigger: 'item',
		        formatter: "{a} <br/>{b}: {c} ({d}%)"
		    },
		    legend: {
		        orient: 'vertical',
		        x: 'left',
		        data:['男','女','未获取']		    
		    },
		    color:['#1AB394','#76D2BF','#BAE9DF'],
		    series: [
		        {
		            name:'访问来源',
		            type:'pie',
		            radius: ['50%', '70%'],
		            avoidLabelOverlap: false,
		            label: {
		                normal: {
		                    show: false,
		                    position: 'center'
		                },
		                emphasis: {
		                    show: true,
		                    textStyle: {
		                        fontSize: '30',
		                        fontWeight: 'bold'
		                    }
		                }
		            },
		            labelLine: {
		                normal: {
		                    show: false
		                }
		            },
		            data:sexData
		        }
		    ]
		};
	sexPie.setOption(sexOption);
}
//操作系统环形图初始化
function initSystemPie(type){
	var systemPie = echarts.init($("."+type+"-pie-system")[0]);
	systemPie.showLoading();
	var initPieUrl = path+"/materialCount/findSystemCount";
	var pieData;
	var systemData = new Array();
	$.ajax({
		type:"post",
		url:initPieUrl,
		async: false,
		data:{
			"startDate" : searchData.startDate,
	  		"endDate" : searchData.endDate,
	  		"aemIds" : searchData.aemIds,
	  		"cityCode" :searchData.cityCode,
	  		"countType" : searchData.countType
		},
    	success:function(data){
    	  if(data.status="200"){
    		  pieData=data.data;
    	  }
    	}
    });
	systemData=[{"name":"安卓","value":"0"},{"name":"IOS","value":"0"},{"name":"WP","value":"0"},{"name":"其他","value":"0"}];
	if(StringEmpty(pieData)){
		for(var i=0;i<pieData.length;i++){
			var data = new Object();
			var name =pieData[i].phoneType=="android"?"安卓":pieData[i].phoneType=="ios"?"IOS":pieData[i].phoneType=="wap"?"WAP":"其他";
			var value=pieData[i].materialCount;
			for(var j=0;j<systemData.length;j++){
				var system = systemData[j];
				if(name==system.name){
					system.value=value;
				}
			}
		}
	}
	systemPie.hideLoading();
	var systemOption = {
		    tooltip: {
		        trigger: 'item',
		        formatter: "{a} <br/>{b}: {c} ({d}%)"
		    },
		    legend: {
		        orient: 'vertical',
		        x: 'left',
		        data:['IOS','安卓','WP','其他']
		    },
		    color:['#1AB394','#76D2BF','#BAE9DF','#D8FFF7'],
		    series: [
		        {
		            name:'访问来源',
		            type:'pie',
		            radius: ['50%', '70%'],
		            avoidLabelOverlap: false,
		            label: {
		                normal: {
		                    show: false,
		                    position: 'center'
		                },
		                emphasis: {
		                    show: true,
		                    textStyle: {
		                        fontSize: '30',
		                        fontWeight: 'bold'
		                    }
		                }
		            },
		            labelLine: {
		                normal: {
		                    show: false
		                }
		            },
		            data:systemData
		        }
		    ]
		};
	systemPie.setOption(systemOption);
}
//来源环形图初始化
function initSourcePie(type){
	var sourcePie = echarts.init($("."+type+"-pie-source")[0]);
	sourcePie.showLoading();
	var initPieUrl = path+"/materialCount/findSourceCount";
	var pieData;
	var sourceData = new Array();
	$.ajax({
		type:"post",
		url:initPieUrl,
		async: false,
		data:{
			"startDate" : searchData.startDate,
	  		"endDate" : searchData.endDate,
	  		"aemIds" : searchData.aemIds,
	  		"cityCode" :searchData.cityCode,
	  		"countType" : searchData.countType
		},
    	success:function(data){
    	  if(data.status="200"){
    		  pieData=data.data;
    	  }
    	}
    });
	var legendData = new Array();
	if(StringEmpty(pieData)){
		for(var i=0;i<pieData.length;i++){
			var data = new Object();
			var name = pieData[i].aemName;
			var value=pieData[i].materialCount;
			legendData.push(name);
			data.name=name;
			data.value=value;
			sourceData.push(data);
		}
	}else{
		legendData=['暂无'];
		sourceData=[{'name':'暂无',"value":"0"}];
	}
	sourcePie.hideLoading();
	var sourceOption = {
		    tooltip: {
		        trigger: 'item',
		        formatter: "{a} <br/>{b}: {c} ({d}%)"
		    },
		    legend: {
		        orient: 'vertical',
		        x: 'left',
		        data:legendData
		    },
		    color:['#1AB394','#76D2BF','#BAE9DF','#D8FFF7','#8CA7E5'],
		    series: [
		        {
		            name:'访问来源',
		            type:'pie',
		            radius: ['50%', '70%'],
		            avoidLabelOverlap: false,
		            label: {
		                normal: {
		                    show: false,
		                    position: 'center'
		                },
		                emphasis: {
		                    show: true,
		                    textStyle: {
		                        fontSize: '30',
		                        fontWeight: 'bold'
		                    }
		                }
		            },
		            labelLine: {
		                normal: {
		                    show: false
		                }
		            },
		            data:sourceData
		        }
		    ]
		};
	sourcePie.setOption(sourceOption);
}
//分享列表
function shareDataTable(){
 	return $('#shareTable').DataTable({
 		processing: true,
 		ordering: false,
 		searching: false,
 		info: true,
 		autoWidth: true,
 		lengthChange: false,
 	    language: {
 	    	emptyTable: '<div id="content_empty"  class="form-group white-bg" style="text-align:center;padding:200px 0;margin:0;">   <p>暂无数据</p></div>',
 	    	info: '从第 _START_ 到第 _END_ 条数据；总共有 _TOTAL_ 条记录',
 			infoEmpty: '没有数据',
 			lengthMenu: '每页显示 _MENU_ 条记录',
 			loadingRecords: '正在加载数据....',
 			processing: '正在处理数据....',
 			zeroRecords: '没有找到匹配的记录',
 			paginate: {
 				first: '首页',
 				previous: '前页',
 				next: '后页',
 				last: '尾页'
 			}
 	    },
 		pageLength: 10,
 	    pagingType: 'full_numbers',        	     
 	    columns: func_columns(),
 	    columnDefs: [{
     	    	render: function(data, type, full) {
     	    		var innerHtml="未知";
         	    	if(data=="m"){
         	    		innerHtml="男";
         	    	}else if(data=="f"){
         	    		innerHtml="女";
         	    	}
    				return innerHtml;
            },
			targets: 1
     		},{
     	    	render: function(data, type, full) {
     	    		var innerHtml=data;
    				return innerHtml;
            },
			targets: 5
     		}],  
 	    serverSide: true,
 	    ajax: {
 	    	contentType: 'application/json',
 	    	type: 'POST',
 	    	url: func_AjaxUrl(),
 	    	data: function(d){
 				d.extra_search = func_ajaxData();
 				return JSON.stringify(d);
 	    	}	
 	    }
 	});
 	 function func_AjaxUrl(){
      	return path+"/materialCount/ajaxSharePageByDto";
      }
 	 /**
 	  *	后台查询条件
 	  */
 	 function func_ajaxData(){
 		var jsonObject = new Object();
  		jsonObject.startDate = searchData.startDate;
  		jsonObject.endDate = searchData.endDate;
  		jsonObject.aemIds = searchData.aemIds;
	 	return jsonObject;
 	 }
      /**
       *	设置列名，对应后台
       */
      function func_columns(){
       	var jsonArr = [
             {'data':'nickName'},
             {'data':'sex'},
             {'data':'areaName'},
         	 {'data':'userIdentity'},
         	 {'data':'aemName'},
       	   	 {'data':'lastAttentionTime'},
   		     {'data':'shareCount'}];
      	return jsonArr;
      }
 }
//提表列表
function submitDataTable(){
 	return $('#submitTable').DataTable({
 		processing: true,
 		ordering: false,
 		searching: false,
 		info: true,
 		autoWidth: true,
 		lengthChange: false,
 	    language: {
 	    	emptyTable: '<div id="content_empty"  class="form-group white-bg" style="text-align:center;padding:200px 0;margin:0;">   <p>暂无数据</p></div>',
 	    	info: '从第 _START_ 到第 _END_ 条数据；总共有 _TOTAL_ 条记录',
 			infoEmpty: '没有数据',
 			lengthMenu: '每页显示 _MENU_ 条记录',
 			loadingRecords: '正在加载数据....',
 			processing: '正在处理数据....',
 			zeroRecords: '没有找到匹配的记录',
 			paginate: {
 				first: '首页',
 				previous: '前页',
 				next: '后页',
 				last: '尾页'
 			}
 	    },
 		pageLength: 10,
 	    pagingType: 'full_numbers',        	     
 	    columns: func_columns(),
 	    columnDefs: [{
     	    	render: function(data, type, full) {
     	    	var innerHtml="未知";
     	    	if(data=="m"){
     	    		innerHtml="男";
     	    	}else if(data=="f"){
     	    		innerHtml="女";
     	    	}
				return innerHtml;
            },
			targets: 2
     		},{
     	    	render: function(data, type, full) {
         	    	var innerHtml="————";
         	    	if(StringEmpty(data)){
	         	    	var date = new Date(data);
	        	        innerHtml = timeFormatLong(date);
	        	     }
    				return innerHtml;
                },
    			targets: 5
         		}],  
 	    serverSide: true,
 	    ajax: {
 	    	contentType: 'application/json',
 	    	type: 'POST',
 	    	url: func_AjaxUrl(),
 	    	data: function(d){
 				d.extra_search = func_ajaxData();
 				return JSON.stringify(d);
 	    	}	
 	    }
 	});
 	 function func_AjaxUrl(){
      	return path+"/materialCount/ajaxSubmitPageByDto";
      }
 	 /**
 	  *	后台查询条件
 	  */
 	 function func_ajaxData(){
 		var jsonObject = new Object();
  		jsonObject.startDate = searchData.startDate;
  		jsonObject.endDate = searchData.endDate;
  		jsonObject.aemIds = searchData.aemIds;
	 	return jsonObject;
 	 }
      /**
       *	设置列名，对应后台
       */
      function func_columns(){
       	var jsonArr = [
       	     {'data':'memberName'},
             {'data':'memberPhone'},
             {'data':'sex'},
         	 {'data':'userIdentity'},
         	 {'data':'aemName'},
       	   	 {'data':'createTime'},
   		     {'data':'cancelStatus'}];
      	return jsonArr;
      }
 }
 //导出传播数据csv文件
$(".export-share").click(function(){
	if(StringEmpty(searchData.aemIds)&&searchData.aemIds!=0){
		var exportShareUrl = path+"/materialCount/exportShareInfo?aemIds="+searchData.aemIds+"&startDate="+searchData.startDate+"&endDate="+searchData.endDate+"&mgiId="+materialId;
		window.location.href=exportShareUrl;
	}
})
//导出提表数据csv文件
$(".export-submit").click(function(){
	if(StringEmpty(searchData.aemIds)&&searchData.aemIds!=0){
		var exportSubmitUrl = path+"/materialCount/exportSubmitInfo?aemIds="+searchData.aemIds+"&startDate="+searchData.startDate+"&endDate="+searchData.endDate+"&mgiId="+materialId;
		window.location.href=exportSubmitUrl;
	}
})
	function func_artdialog(name,value){
 		var d = dialog({
 			title: name,
 			fixed: true,
 			width: 200,
 	        height:100,
 			content:"<center style='font-size:20px; line-height:100px;'>"+value+"</center>",
 			okValue: "确定",
 			ok: function () {
 				return true;
 			}
 		});
 		d.show();
 	}
	//判断字符串是否为空
    function StringEmpty(content) {
        if (content == undefined || content == "" || content == null) {
            return false;
        } else {
            return true;
        }
    }
	//时间格式化为yyyy-mm-dd
	function timeFormat(date){
		var y = date.getFullYear();    
		var mon = date.getMonth()+1;//获取当前月份的日期   
		var d = date.getDate(); 
		return  timeMakeLong(y)+"-"+timeMakeLong(mon)+"-"+timeMakeLong(d);
	}
	//时间格式化为yyyy-mm-dd hh:mm
	function timeFormatLong(date){
		var y = date.getFullYear();    
		var mon = date.getMonth()+1;//获取当前月份的日期   
		var d = date.getDate(); 	
		var h=date.getHours();//小时 
        var m=date.getMinutes(); //分 
        return  timeMakeLong(y)+"-"+timeMakeLong(mon)+"-"+timeMakeLong(d)+" "+timeMakeLong(h)+":"+timeMakeLong(m);
	}
	//时间补0
	function timeMakeLong(data){
		if((data+"").length==1){
			return "0"+data;
		}
		return data;
	}
</script>
</html>